home *** CD-ROM | disk | FTP | other *** search
- /* vprintf.c --- p 479 */
- #include <stdio.h>
- #include <stdarg.h> /* ANSI C compatible */
- void error_handler(char *,...);
- char filename[80] = "COMMAND.COM";
- main()
- {
- int offset = 0x232A;
- /* Call the error handler to print an error message.
- * First just a single line. Then a more detailed
- * message with more arguments. */
- error_handler("System error\n");
- error_handler("File %s at offset %x\n", filename, offset);
- }
- /*--------------------------------*/
- /* error_handler: accepts variable number of arguments
- * and prints messages */
- void error_handlerf(char *my_format,...)
- {
- va_list arg_pointer;
- /* Use va_start macro to get to the start of the
- * variable number of arguments. This will alter the
- * pointer arg_pointer to point to the list of
- * variables to be printed. */
- va_start(arg_pointer, my_format);
- vprintf(my_format, arg_pointer);
- /* Use the va_end macro to reset the arg_pointer */
- va_end(arg_pointer);
- }